//
//  BKVistorTableViewController.swift
//  微博
//
//  Created by mac on 16/8/9.
//  Copyright © 2016年 xbk. All rights reserved.
//

import UIKit

class BKVistorTableViewController: UITableViewController {

    //是否登录的标记
    var isLogin :Bool = BKUserAccountViewModel.shareUserAccount.userAccount?.access_token != nil
    
    var vistorView :BKVistorView?
    
    override func loadView() {
        
        if isLogin{
        
            super.loadView()
        }else{
        
            vistorView = BKVistorView()
            vistorView?.loginClosure = {[weak self] in
            
                self?.reqeustOAuthVC()
            }
            view = vistorView
            setNavUI()
        }
        
        
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    private func setNavUI() {
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "loginAction")
        
        
    }

    private func reqeustOAuthVC() {
        
       // print("登录新浪微博页面")
        let oAuthVC = BKOAuthViewController()
        let nav = UINavigationController(rootViewController: oAuthVC)
        presentViewController(nav, animated: true, completion: nil)
    }

    func registerAction (){
    
        print("注册")
        reqeustOAuthVC()
    }

    func loginAction () {
    
        print("等录")

    }
    

}
